{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "方法一：直接通过一个`class`的静态变量`class`获取："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-29T13:26+0000",
     "start_time": "2020-09-29T13:26:21.839Z"
    }
   },
   "outputs": [],
   "source": [
    "Class cls = String.class;"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "方法二：如果我们有一个实例变量，可以通过该实例变量提供的`getClass()`方法获取："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-29T13:28+0000",
     "start_time": "2020-09-29T13:28:24.203Z"
    }
   },
   "outputs": [],
   "source": [
    "String s = \"Hello\";\n",
    "Class cls = s.getClass();"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "方法三：如果知道一个`class`的完整类名，可以通过静态方法`Class.forName()`获取："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-29T13:30+0000",
     "start_time": "2020-09-29T13:30:35.077Z"
    }
   },
   "outputs": [],
   "source": [
    "Class cls = Class.forName(\"java.lang.String\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-29T13:30+0000",
     "start_time": "2020-09-29T13:30:37.235Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "class java.lang.String\n"
     ]
    }
   ],
   "source": [
    "System.out.println(cls);"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Java",
   "language": "java",
   "name": "java"
  },
  "language_info": {
   "codemirror_mode": "java",
   "file_extension": ".jshell",
   "mimetype": "text/x-java-source",
   "name": "Java",
   "pygments_lexer": "java",
   "version": "11.0.8+10-post-Ubuntu-0ubuntu120.04"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
